﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Model
{
    /// <summary>
    /// 盘点单主表实体类，对应数据库表 dbo.wh_stock_take
    /// </summary>
    public class WhStockTake
    {
        /// <summary>
        /// 盘点单ID（主键）
        /// </summary>
        [Key]
        public long InventoryOrderId { get; set; }

        /// <summary>
        /// 仓库ID
        /// </summary>
        public long WarehouseId { get; set; }

        /// <summary>
        /// 盘点单号
        /// </summary>
        public string InventoryOrderNo { get; set; }

        /// <summary>
        /// 源单号
        /// </summary>
        public string? SourceOrderNo { get; set; }

        /// <summary>
        /// 盘点类型
        /// </summary>
        public string InventoryType { get; set; }

        /// <summary>
        /// 盘点开始时间
        /// </summary
        public DateTime InventoryStartTime { get; set; }

        /// <summary>
        /// 盘点结束时间
        /// </summar
        public DateTime InventoryEndTime { get; set; }

        /// <summary>
        /// 操作人员
        /// </summary>
        public long OperatorBy { get; set; }

        /// <summary>
        /// 操作日期
        /// </summary>
        public DateTime OperatorDate { get; set; }

        /// <summary>
        /// 入库标识
        /// </summary>
        public string Inbound { get; set; }

        /// <summary>
        /// 出库标识
        /// </summary>
        public string Outbound { get; set; }

        /// <summary>
        /// 订单状态
        /// </summary>
        public string OrderStatus { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public long? AuditorBy { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditorTime { get; set; }

        /// <summary>
        /// 审核备注
        /// </summary>
        public string? AuditorComment { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public long CreateBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 更新人
        /// </summary>
        public long UpdateBy { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }

    }

    /// <summary>
    /// 盘点单聚合数据DTO（前端展示用）
    /// </summary>
    public class InventoryAggregateDTO
    {
        public long warehouse_id { get; set; }
        public string warehouse_name { get; set; }
        public long inventory_order_id { get; set; }
        public string inventory_order_no { get; set; }
        public string order_status { get; set; }
        public DateTime create_time { get; set; }
        public string goods_names { get; set; }
        public decimal inventory_quantity { get; set; }
        public decimal total_profit_quantity { get; set; }
        public decimal total_loss_quantity { get; set; }
        public decimal total_profit_amount { get; set; }
        public decimal total_loss_amount { get; set; }
        public string create_by { get; set; }
        public string create_org_name { get; set; }
        public string auditor_by { get; set; }
        public string inventory_type { get; set; } 
        public DateTime inventory_start_time { get; set; }
        public DateTime inventory_end_time { get; set; }
        public string inbound { get; set; }  // 入库状态
        public string outbound { get; set; } // 出库状态
    }

    /// <summary>
    /// 仓库-库位-库存-商品关联DTO
    /// </summary>
    public class WarehouseLocationGoodsDTO
    {
        // 商品信息
        public long GoodsId { get; set; }
        public string GoodsCode { get; set; }
        public string GoodsName { get; set; }
        public string Specification { get; set; }
        public string GoodsType { get; set; } // 新增货品类型

        // 库存（库位明细）信息
        public decimal AvailableQty { get; set; } // 库位明细中的库存数量
        public decimal UnitPrice { get; set; }    // 单价

        // 库位信息
        public long StorageLocationId { get; set; }
        public string StorageLocationName { get; set; }

        // 仓库信息
        public long WarehouseId { get; set; }
        public string WarehouseName { get; set; }
    }

    // 新增的列表模型
    public class WhStockTakeListModel
    {
        public long InventoryOrderId { get; set; }
        public string InventoryOrderNo { get; set; }
        public string WarehouseName { get; set; }
        public string InventoryTypeName { get; set; }
        public DateTime InventoryStartTime { get; set; }
        public DateTime InventoryEndTime { get; set; }
        public string OperatorName { get; set; }
        public string CreatorName { get; set; }
        public string DepartmentName { get; set; }
        public string OrderStatus { get; set; }
        public string Inbound { get; set; }
        public string Outbound { get; set; }
        public int InventoryGoodsCount { get; set; }
        public decimal InventoryQuantity { get; set; }
        public decimal ProfitQuantity { get; set; }
        public decimal LossQuantity { get; set; }
        public decimal ProfitAmount { get; set; }
        public decimal LossAmount { get; set; }
        public DateTime CreateTime { get; set; }
    }
}
